<!-- 简历管理 -->
<template>
  <div class="rthcHead">
    <div class="rthcImg">
      <img src="@/assets/img/personnelImage/岗位需求库.png">
      <span class="rthcTi" title="简历管理">简历管理</span>
    </div>
  </div>
  <div class="rthc-handle">
      <span class="rthc-handle-pri">
<!--        <el-button type="primary">发送岗位推荐</el-button>-->
      </span>
    <span class="rthc-handle-more">
       <el-dropdown>
          <el-icon>
            <setting/>
          </el-icon>
          <template #dropdown>
            <el-dropdown-menu>
<!--              <el-dropdown-item>新建</el-dropdown-item>-->
              <el-dropdown-item @click="resudel">删除</el-dropdown-item>
<!--              <el-dropdown-item>修改</el-dropdown-item>-->
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </span>
  </div>
  <div style="height: 100%; min-height: 235px;">
    <div style="background: white">
      <div class="rthcink">
        <span class="rthc-quickearch-label">
          岗位名称 :
        </span>
        <div class="rthc-quickearch-style">
          <el-input v-model="pub_channel_id"
                    :value.async="positionName"
                    placeholder="岗位名称"
                    @focus="dialogTableVisible = true" @change="Visdemand"
                    @keyup.enter.native="Visdemand" clearable/>
        </div>
      </div>
      <div class="rthcink">
        <span class="rthc-quickearch-label">
          应聘人 :
        </span>
        <div class="rthc-quickearch-style">
          <el-input
              v-model="id" placeholder="应聘人姓名"
              :value.async="name"
              @focus="fabuTabVis = true"
              @keyup.enter.native="Visdemand"
              @change="Visdemand" clearable/>
        </div>
      </div>
    </div>
    <div class="rthc-list-table">
      <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
        <el-tab-pane
            v-for="(item, index) in type_option"
            :key="index"
            :name="item.optValue.toString()"
            :label="item.optName"
        >
        </el-tab-pane>
        <div class="rthc-list-table">
          <el-table
              ref="multipleTable"
              :data="tableData"
              tooltip-effect="dark"
              style="width: 100%"
              :header-cell-style="{background:'#F7FBFE',color:'#606266'}"
              @selection-change="handleSelectionChange">
            <el-table-column
                prop="id"
                type="selection"
                width="55">
            </el-table-column>
            <el-table-column
                prop="name"
                label="姓名"
                width="120">
            </el-table-column>
            <el-table-column
                prop="sex"
                label="性别"
                width="75">
            </el-table-column>
            <el-table-column
                prop="resumeClassify.positionName"
                label="应聘岗位"
                show-overflow-tooltip>
            </el-table-column>
            <el-table-column
                prop="highestEducation"
                label="最高学历"
                show-overflow-tooltip>
              <template #default="s">
                {{this.$dictMap.getLabel(`hEducationName:${s.row.highestEducation}`)}}
              </template>
            </el-table-column>
            <el-table-column
                prop="resumeClassify.talentLevel"
                label="紧跟类型"
                show-overflow-tooltip>
              <template #default="s">
                {{this.$dictMap.getLabel(`t_level:${s.row.resumeClassify.talentLevel}`)}}
              </template>
            </el-table-column>
            <el-table-column
                prop="resumeClassify.tag"
                label="标签"
                width="80"
                show-overflow-tooltip>
              <template #default="s">
                {{this.$dictMap.getLabel(`resume_tag:${s.row.resumeClassify.tag}`)}}
              </template>
            </el-table-column>
            <el-table-column
                prop="createTime"
                label="更新时间"
                show-overflow-tooltip>
            </el-table-column>
            <el-table-column
                prop="status"
                label="操作"
                show-overflow-tooltip>
              <template #default="xx">
                <el-tag type="warning" v-if="xx.row.status === 0" @click="atlzpLink(xx.row)">查询员工卡片</el-tag>
                <el-tag type="success" v-else-if="xx.row.status === 1" @click="atlzpLink(xx.row)">查询简历</el-tag>
                <el-tag v-else-if="xx.row.status === 2">审批驳回</el-tag>
              </template>
            </el-table-column>
          </el-table>
          <div class="pag-block" style="">
            <el-pagination
                v-if="pageShow"
                @current-change="handleCurrentChange"
                :total="arr.total"
                :page-size="arr.pageSize"
                :hide-on-single-page="hidePaging"
            >
            </el-pagination>
          </div>
        </div>
      </el-tabs>
    </div>
  </div>

  <el-dialog v-model="dialogTableVisible" title="应聘部门">
    <el-table :data="diatable" @row-click="bydiaval">
      <el-table-column property="value" label="编号" width="200"/>
      <el-table-column property="label" label="岗位" width="auto"/>
    </el-table>
  </el-dialog>
  <el-dialog v-model="fabuTabVis" title="发布人">
    <el-table :data="fabtable" @row-click="byfabval">
      <el-table-column property="id" label="编号" width="200"/>
      <el-table-column property="name" label="姓名" width="auto"/>
    </el-table>
  </el-dialog>
</template>

<script>
import {delResume, selAll} from '../../../network/per/inter'
import {getDeptOptions} from "../../../network/sys/dept";
export default {
 data(){
   return{
     dialogTableVisible:false,
     fabuTabVis:false,
     diatable:[],
     fabtable:[],
     activeName: 'second',
     // 展示
     tableData:[],
     hidePaging: false,
   //  简历来源
     type_option: [
       {
         optValue: 0,
         optName: '全部'
       }, {
         optValue: 1,
         optName: '51job'
       }, {
         optValue: 2,
         optName: '猎聘网'
       }, {
         optValue: 3,
         optName: 'BOSS直聘'
       }, {
         optValue: 4,
         optName: '内推'
       },
     ],
   //  选择列
     multipleSelection:[],

     positionName:"",
     name:"",

   //  查询条件
     pageShow:true,
     arr:
         {
           id: null,
           pub_channel_id: null,
           pageSize: 5,
           pageNum: 1,
         }
   };
 },
  mounted() {
   this.init();
    getDeptOptions().then(data => {
      this.$response.handle({
        data: data,
        successFn: () => {
          this.diatable = data.data
        }
      })
    });
  },
  methods:{
   init(){
     selAll(this.arr).then(das=>{
       console.log("初始化数据resumeManagement -> ",das)
       this.fabtable = das.data.list;
       this.tableData = das.data.list;
       this.arr.total = das.data.total;
       this.arr.pageSize = das.data.pageSize;
       this.arr.pageNum = das.data.pageNum;
     })
   },
   // 简历删除
    resudel(){
      this.$operate.removeBatch({
        title: '删除简历',
        selection: this.multipleSelection,
        key: 'id',
        executeFn: (ids)=>{
          delResume(ids)
        }
      })
    },
   // 简历编辑
    atlzpLink(val){
      this.$router.push({
        path:"/redit",
        query:{
          par:val.id
        }
      })
    },
    // 选择岗位
    bydiaval(row) {
      this.positionName = row.label;
      this.arr.pub_channel_id = row.value;
    },
    // 选择应聘人员
    byfabval(row) {
      this.name = row.name;
      this.arr.id = row.id;
    },
    //获取岗位
    Visdemand(item) {
      console.log("缓存",this.arr)
      this.init();
      // selAll(this.arr).then(das=>{
      //   this.fabtable = das.data.list;
      //   this.tableData = das.data.list;
      //   this.arr.total = das.data.total;
      //   this.arr.pageSize = das.data.pageSize;
      //   this.arr.pageNum = das.data.pageNum;
      // })
    },
    // 选择列
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      if (this.currentPage * val > this.total) return
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.arr.page = val - 1;
      this.arr.pageNum = val;

      let pageMax = Math.ceil(this.arr.total / this.arr.pageSize)
      // 判断跳转页数是否大于最大页数，如果大于，跳转页数就等于最大页数
      if (this.arr.pageNum > pageMax) {
        this.arr.pageNum = pageMax
      }
      this.init();
      // selAll(this.arr).then((des)=>{
      //   this.tableData = des.list;
      //   this.arr.total = des.total;
      //   this.arr.pageSize = des.pageSize;
      //   this.arr.pageNum = des.pageNum;
      // })

    },
    handleClick(tab) {
      this.arr.status = tab.index;
      this.init();
      // selAll(this.arr).then((das)=>{
      //   this.tableData = das.data.list;
      //   this.arr.total = das.data.total;
      //   this.arr.pageSize = das.data.pageSize;
      //   this.arr.pageNum = das.data.pageNum;
      // });
      console.log("缓存",this.arr)
    },
  }
}
</script>

<style lang="scss" scoped>
@import "../../../assets/css/personnelCss/RecruitHeadcount";
.demo-tabs{
  margin-left: 2em;
}
</style>
